package model.serializer;

import com.alibaba.fastjson.JSON;

/**
 * @Description 使用Json实现序列化和反序列化
 * @author 14548
 */
public class JsonSerializer implements Serializer {

    @Override
    public byte[] serialize(Object object) {

        return JSON.toJSONBytes(object);
    }

    @Override
    public <T> T deserializer(Class<T> clazz, byte[] bytes) {

        return JSON.parseObject(bytes, clazz);

    }

    @Override
    public byte getSerializerAlgorithm() {

        return SerializerAlgorithm.JSON;
    }
}
